package jp.sourceforge.akjrcp.akj_betas.wizards;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;

public class ChooseOutputWizardPage extends WizardPage{

	private Text outputText;
	private Button launchDVDStyler;

	protected ChooseOutputWizardPage(String pageName) {
		super(pageName);
		// TODO Auto-generated constructor stub
		//setPageComplete(false); //test
	}

	public boolean isLaunch(){
		return launchDVDStyler.getSelection();
	}
	public void createControl(Composite parent) {
		Composite composite=new Composite(parent,SWT.NULL);
		composite.setLayout(new GridLayout(1,false));
		Group panel=new Group(composite,SWT.NONE);
		panel.setText("export xml");
		panel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		panel.setLayout(new GridLayout(2,false));
		outputText = new Text(panel,SWT.READ_ONLY);
		outputText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		outputText.setText(System.getProperty("user.dir")+"\\dvsstyler.xml");
		Button bt=new Button(panel,SWT.NULL);
		bt.addSelectionListener(new SelectionAdapter(){
			public void widgetSelected(SelectionEvent e) {
				chooseSaveFile();
			}
		});
		bt.setText("explorer");
		
		launchDVDStyler = new Button(panel,SWT.CHECK);
		launchDVDStyler.setText("launch");
		launchDVDStyler.setSelection(true);
		
		setControl(composite);
	}
	
	public String getSavePath(){
		return outputText.getText();
	}
	
	public void chooseSaveFile(){
		FileDialog dialog=new FileDialog(getShell(),SWT.SAVE);
		dialog.setFilterExtensions(new String[]{"*.xml"});
		String path=dialog.open();
		
		if(path!=null){
			outputText.setText(path);
			setPageComplete(true);
		}
	}
	

	
}
